let Web3 = require('web3');
let web3 = new Web3();

web3.setProvider(new Web3.providers.HttpProvider('http://localhost:8545'));
console.log(web3.version);
let {interface,bytecode} = require('./compile');
let accounts;
let contractInstance;
deploy = async () => {
    try {

        //获取部署账户
        accounts = await web3.eth.getAccounts();
        contractInstance = await new web3.eth.Contract(JSON.parse(interface)).deploy(
            {
                data: bytecode,
                // arguments: ['']// 构造函数如果没有参数，就一定不要传
            }
        ).send({
            from: accounts[0],
            gas: '1000000'
        })
        console.log('address :', contractInstance.options.address)
    } catch (e) {
        console.log(e)
    }
}

deploy();
